package com.toobigtofail
{
	import com.toobigtofail.drum.DrumListener;
	import com.toobigtofail.drum.Notes;
	import com.toobigtofail.entities.Background;
	import com.toobigtofail.entities.DrumBeatDisplay;
	import com.toobigtofail.entities.DrumTest;
	import com.toobigtofail.entities.Village;
	
	import flash.geom.Point;
	
	import net.flashpunk.FP;
	import net.flashpunk.World;
	import net.flashpunk.utils.Input;
	import net.flashpunk.utils.Key;
	
	public class Game extends World
	{
		private var _drumListeners:Array = new Array;
		public const DEFAULT_BEAT:Number = 0.5;
		public const PLAYER_BASE:Point = new Point(102,245);
		public const ENEMY_BASE:Point = new Point(924,245);
		
		public var fightLine:Number = FP.width/2;
		
		private var _background:Background = new Background();
		
		private var _maintenanceDrumBeatDisplay:DrumBeatDisplay;
		private var _attackDrumBeatDisplay:DrumBeatDisplay;
		
		public function Game()
		{
			super();
			
			Notes.mapNote(Key.A, Notes.A);
			Notes.mapNote(Key.S, Notes.B);
			Notes.mapNote(Key.K, Notes.C);
			Notes.mapNote(Key.L, Notes.D);
			
			_maintenanceDrumBeatDisplay = new DrumBeatDisplay(50, 50);
			_maintenanceDrumBeatDisplay.addPattern("A.A.B");
			_maintenanceDrumBeatDisplay.addPattern("A.B.B");
			_maintenanceDrumBeatDisplay.addPattern("B.A.B");
			
			_maintenanceDrumBeatDisplay.setDrums(Notes.A, Notes.B);
			
			_attackDrumBeatDisplay = new DrumBeatDisplay(200, 50);
			_attackDrumBeatDisplay.addPattern("C.C.D");
			_attackDrumBeatDisplay.addPattern("D.D.D");
			_attackDrumBeatDisplay.addPattern("C.C.C");
			
			_attackDrumBeatDisplay.setDrums(Notes.C, Notes.D);
		}
		
		override public function begin():void
		{
			super.begin();
			
			add(_background);
			add(new Village(false));
			add(new Village(true));
			
			add(_maintenanceDrumBeatDisplay);
			add(_attackDrumBeatDisplay);
			
			/*
			var adt:DrumTest = new DrumTest(200, 200, "AAA|BBB");
			// Set this as a "maintenance" drum, meaning it only cares about those drum keys
			adt.setDrums(Notes.A, Notes.B);
			add(adt);
			
			var adt2:DrumTest = new DrumTest(600, 200, "CCC|DDD");
			// Set this as a "attack" drum, meaning it only cares about those drum keys
			var a:Array = adt2.setDrums(Notes.C, Notes.D);
			add(adt2);
			*/
			
		}
		
		
		override public function update():void {
			super.update();
		}
	}
}